// const { default: axios } = require("axios");

const onfocusFun = e => {
     e=e || window.event;
    var target=e.target || e.srcElement;
  }
const onblurFun = e => {
     e=e || window.event;
    var target=e.target || e.srcElement;
  }

//  获取后台数据，渲染页面
var tybody = qu("#tybody");
var page=1,
   pageSize=10,
   datas,
   counts; 
function initFun(){
    var getcounts = ()=> {
        return new Promise((resolve, reject) => {
            axios({
                url:"/admin/index/findAllInterviews",
                method:"GET",
                }).then(data=>{
                    resolve(data)
                });
        })
        
    }
    getcounts().then(data=>{
        counts=data.data.object.length
        layui.use(['laypage', 'layer'], function(){
            // console.log(counts);
            let arr_length =new Array();
            if(counts<=10){
                arr_length=[counts];
            }else if(counts<=20&&counts>10){
                arr_length=[10,counts];
            }else if(counts>20&&counts<=50){
                arr_length=[10,20,counts];
            }else if(counts>50){
                arr_length=[10,20,50,counts];
            }
           var laypage = layui.laypage
           ,layer = layui.layer;
           laypage.render({
               elem: 'demo7'
               ,count: counts
               ,curr:page
               ,limit:pageSize
               ,limits: arr_length
               ,layout: ['count', 'prev', 'page', 'next', 'limit']
               ,jump: function(obj){
                 page=obj.curr;
                 pageSize=obj.limit;
                 getData(page,pageSize);
                 dels=[]
                 checkAll.checked = false;
               }
           });
        });
        
    });
}
initFun();

const getData=(a,b)=>{
   // 传参
   if(pageSize>=counts) pageSize=counts;
   // 获得数据
   axios({  
    url:"/admin/index/findAllInterviews",
    method:"GET",
    })
    .then(function(result){
        console.log(result);
        datas=result.data.Object
        tybody.innerHTML=''
        let i;
            for(i=(a-1)*pageSize; i<((a-1)*pageSize+pageSize); i++){
                tybody.innerHTML +=`
                <tr>
                    <td><input type="checkbox" class="checkbox"  onclick="checkboxFun()" name="${result.data.object[i].interviewersId}" target="${i}"  ></td>
                    <td>${i+1}、${result.data.object[i].name}</td>
                    <td>${result.data.object[i].classes}</td>
                    <td>${result.data.object[i].studentId}</td>
                    <td>${result.data.object[i].state}</td>
                    
                    <td>
                        <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="seejudgeFun()" target="${result.data.object[i].interviewersId}" name="${result.data.object[i].classes+result.data.object[i].name}" style="background-color:#ff4700">
                            评论
                        </button>
                        <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="openCheckWindow()" target="${result.data.object[i].studentId}" name="${result.data.object[i].state}" >
                            详情
                        </button>
                        <button class="layui-btn layui-btn-sm layui-btn-sm" onclick="openChangeWindowFun()" _id="${result.data.object[i].interviewersId}" target="${result.data.object[i].studentId}" name="${result.data.object[i].state}" >
                            变更
                        </button>
                        <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="delUserFun()"  target="${result.data.object[i].interviewersId}" >
                            删除

                        </button>
                        <button class="layui-btn layui-btn-warm  layui-btn-sm" target="${result.data.object[i].studentId}" name="${result.data.object[i].state}" onclick="goInterviewFun()" >
                            开始面试
                        </button>
                    </td>
                </tr>
                `
            }
    })
    .catch(err=>{
        console.log(err);
    })
}


// 开启弹窗;
var studentId;
var _Id;
var state;
var checkDetails=document.getElementById('checkDetails')
function openChangeWindowFun(e){
    e=e || window.event;
    var target=e.target || e.srcElement;
    flagChangeType = 0;
    studentId=target.getAttribute("target")
    _Id=target.getAttribute('_id')
    state=target.getAttribute("name")
    changeWindow.style.display="block";
    cover_div[0].style.display="block";
    let right=document.getElementsByClassName('right');
    for(let i=0;i<change_li.length;i++){
        right[i].style.display='none'
        change_li[i].style.backgroundColor="#D8F3EE"
        change_li[i].style.color='rgb(115, 111, 111)'
        if(state=='已淘汰'){
                    state='淘汰'
                }else if(state=='已录取'){
                    state='录取'
                }
            if(change_li[i].innerHTML==state){
                right[i].style.display='block'
                change_li[i].style.backgroundColor="rgb(43, 165, 254)"
                change_li[i].style.color='white'
            }   
    }
}

//查看详情
var interviewIdOrigin;
function openCheckWindow(e){
    checkDetails.style.display='block';
    cover_div[0].style.display="block";
    var infoInput = document.getElementsByClassName('infoInput');
    e=e || window.event;
   var target=e.target || e.srcElement;
    studentId=target.getAttribute('target')
    console.log(studentId);
    axios({
        url:'/admin/index/findByStudentId',
        method:'GET',
        params:{
            studentId:studentId
        }
    }).then(data => {
        console.log(data);
        interviewIdOrigin= data.data.object.interviewersId;
        infoInput[0].value=data.data.object.name;
        infoInput[1].value=data.data.object.sex;
        infoInput[2].value=data.data.object.classes;
        infoInput[3].value=data.data.object.studentId;
        infoInput[4].value=data.data.object.telephone;
        infoInput[5].value=data.data.object.qq;
        infoInput[6].value=data.data.object.state;
        infoInput[7].value=data.data.object.place;
        infoInput[8].value=data.data.object.time;
    })
    .catch(err=>{
        console.log(err);
    })
}
// 关闭弹窗
function closeChangeWindowFun(){
    changeWindow.style.display="none";
    cover_div[0].style.display="none";
    windowDiv.style.display="none";
    checkDetails.style.display="none";
    addUsersBtn.style.display="none";
}
function closeCheckWindow(){
    checkDetails.style.display='none';
    cover_div[0].style.display="none";
    changeWindow.style.display="none";
    windowDiv.style.display="none";
    addUsersBtn.style.display="none"
}
function closeAddWindow(){
    checkDetails.style.display='none';
    cover_div[0].style.display="none";
    changeWindow.style.display="none";
    windowDiv.style.display="none";
    addUsersBtn.style.display="none"
    interviewWindow.style.display="none"
}
// 提交 更改面试者状态
function changeOkFun(){
    // closeChangeWindowFun();
    // let state= chooseStatusFun()
    // console.log(state);
    // console.log(studentId);
    if(state=="淘汰"){
        state="已淘汰"
    }else if(state=="录取"){
        state= "已录取"
    }
   
    // chooseStatusFun(e)
    // e=e || window.event;
    // var target=e.target || e.srcElement;
    // var state = target.getAttribute('state')
    // var studentId = target.getAttribute('studentId')
   if(flagChangeType=='1'){
        changeOkFunA();
   }else{
       axios({
           url:'/admin/index/changeState',
           method:'GET',
           params: {
               state: state,
               studentId: studentId
           }
       }).then(data => {
           // console.log(data);
           // getData(page,pageSize);
           layui.use("layer",function(){
               layer.msg('修改成功', {
                   icon: 1,
                   time: 2000
               })
           })
          console.log(search_inputText);
           if(search_inputText==null){
                if(filter.value=='所有人'){
                    getData(page,pageSize);
                }else{
                    filterSort();
                }
            }else{
                seekFunOk();
           }
           // location.reload();
       })
       initTimePlaceFun(studentId);
       saveInterviews_a(_Id)
   }
   
    closeChangeWindowFun();
    // getData(page,pageSize)
}

// 选择状态
var change_li = cl("change_li");
function chooseStatusFun(e){
    e=e || window.event;
    var target=e.target || e.srcElement;
    
    for(let key of change_li){
        key.style.backgroundColor="#D8F3EE";
        key.style.color="rgb(115, 111, 111)";
    }
    target.style.backgroundColor = "#2BA5FE"
    target.style.color = "#fff"
    state = target.innerHTML;
    // changeOkFun(target.getAttribute('state'),target.getAttribute('studentId'))
}

// 前往面试
function goInterviewFun(e){
    e=e || window.event;
    var target=e.target || e.srcElement;
    goInterviewInput.value = target.getAttribute("target");
    console.log(target.getAttribute("name"));
    console.log(target.getAttribute("target"));
    if(target.getAttribute("name")=='待笔试'){
        // alert('该面试者未笔试，不可进入面试')
        layui.use("layer",function(){
            layer.msg('该面试者未笔试，不可进入面试！', {
                icon: 7,
                time: 2000
            })
        })    
    }else if(target.getAttribute("name")=='已录取'){
        // alert('该面试者已录取')
        layui.use("layer",function(){
            layer.msg('该面试者已录取！', {
                icon: 7,
                time: 2000
            })
        })    
    }else if(target.getAttribute("name")=='已淘汰'){
        // alert('该面试者已淘汰')
        layui.use("layer",function(){
            layer.msg('该面试者已淘汰！', {
                icon: 7,
                time: 2000
            })
        })    
    }else{
        location.href="../admin/interview?id="+target.getAttribute("target")
    }
    
    // goInterviewForm.submit();
}
// 前往表格管理
function goTableFun(){
    location.href = "../admin/tables"
}

//查看详情
function checkDetails(){
    
}

//添加用户
function addUsers(){
    cover_div[0].style.display="block"
    addUsersBtn.style.display="block"
}
var addInput = document.getElementsByClassName('addInput')
function isTelCode(str) {
    var reg= /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
    return reg.test(str);
}
function judgeAdd(){
            if(addInput[0].value==''||addInput[1].value==''||addInput[2].value==''||addInput[3].value==''||addInput[4].value==''||addInput[5].value==''){
            layui.use("layer",function(){
                layer.msg('请完整填写信息', {
                    icon: 7,
                    time: 2000
                })
            })
            
            }else if(!isTelCode(document.getElementById("tel").value)){
                layui.use("layer",function(){
                    layer.msg('请再仔细检查一遍电话号码', {
                        icon: 7,
                        time: 2000
                    })
                })
                document.getElementById("tel").focus();
                return false;
            }else{
                sureAdd();
            }
}
function sureAdd() {
        let sex = document.getElementById('sex')
		console.log(sex.value);
        console.log(addInput[0].value);
		axios({
			url:'/admin/index/addUsersUrl',
			method:'GET',
			params:{
				name: addInput[0].value,
				sex:sex.value,
				classes: addInput[2].value,
				studentId: addInput[3].value,
				Telephone: addInput[4].value,
				qq: addInput[5].value
			}
			})
			.then(data => {
				console.log(data);
				if(data.data.message=='成功'){
					layui.use("layer",function(){
                        layer.msg('添加成功！', {
                            icon: 1,
                            time: 2000
                        })
                    })
                    closeAddWindow()
				}else if(data.data.message=='你已经报过名了！'){
					layui.use("layer",function(){
                        layer.msg('该面试者已被添加', {
                            icon: 7,
                            time: 2000
                        })
                    })
                    closeAddWindow()
				}else{
					layui.use("layer",function(){
                        layer.msg('请检查信息是否有误', {
                            icon: 7,
                            time: 2000
                        })
                    })
				}
			})
			.catch(err => {
				console.log(err);
			})
}

var flagDel = 0;
var delid;
// 删除单个用户
function delUserFun(e){
    e=e || window.event;
   var target=e.target || e.srcElement;
   delid=target.getAttribute("target");
//    console.log(delid);
   cover_div[0].style.display="block"
   windowDiv.style.display="block"
   flagDel = 1;
   
}
// 批量删除
function delUsersFun(){
    if(dels.length==0){
        // alert("请选中您要删除的面试者")
        layui.use("layer",function(){
            layer.msg('请选中您要删除的面试者', {
                icon: 7,
                time: 2000
            })
        })
    }else{
        cover_div[0].style.display="block"
        windowDiv.style.display="block"
        flagDel = 2;
    }
}

function cancleDelFun(){
    cover_div[0].style.display="none"
    windowDiv.style.display="none"
    flagDel=0;
}
function submitDelFun(){
    console.log("132");
    if(flagDel==1){
        axios({
            url:"/admin/index/deleteInterview",
            method:"GET",
            params: {
                _id:delid,
                }
            }).then(data=>{
                // console.log(data.data);
                // console.log(data.data.err);
                closeChangeWindowFun()
                if (data.data.err == undefined) {
                    // getData(page,pageSize);
                    // alert("删除成功")
                    
                    layui.use("layer",function(){
                        layer.msg('删除成功', {
                            icon: 1,
                            time: 2000
                            
                        })
                    })
                    // location.reload();
                    initFun()
                    
                }else{
                    layui.use("layer",function(){
                        layer.msg('删除失败', {
                            icon: 2,
                            time: 2000
                        })
                    })
                }
            });
    }else{
        axios({
            url:"/admin/index/deleteAllInterview",
            method:"GET",
            params: {
                _id:dels,
                }
            }).then(data=>{
                // console.log(data.data);
                // console.log(data.data);
                closeChangeWindowFun()
                if (data.data.err==0) {
                    // getData(page,pageSize);
                    // alert("删除成功")
                    layui.use("layer",function(){
                        layer.msg('删除成功', {
                            icon: 1,
                            time: 2000
                        })
                    })
                    // location.reload();
                    initFun()
                }else{
                    layui.use("layer",function(){
                        layer.msg('删除失败', {
                            icon: 2,
                            time: 2000
                        })
                    })
                }
            });
    }
}

//根据姓名查找面试者
function seekUsersFun(e){
    let nav_bottom = qu(".nav_bottom")
    let findP = qu('.findP')
    search_inputText = search_input.value;
    // console.log('123');
    // console.log(typeof search_input.value);//String
    if ( !search_input.value ){
        // alert("请输入您要查找的面试者姓名")
        layui.use("layer",function(){
            layer.msg('请输入您要查找的面试者姓名', {
                icon: 7,
                time: 2000
            })
        })
    } else {
        // console.log('456');
        axios({
            url:"/admin/index/findByNameLike",
            method:"GET",
            params: {
                name:search_input.value,
                choose:findFlag.value 
                }
            })
            .then(data=>{
                // console.log(data.data.data[0]);
                // console.log(data.data.object);
                // console.log(data.data.object.length);
                // console.log(data.data.length);
                // console.log(data.status);
                if(data.status==200){   
                    if(data.data.object==null){
                        // alert('抱歉未找到')
                        layui.use("layer",function(){
                            layer.msg('抱歉未找到', {
                                icon: 7,
                                time: 2000
                            })
                        })
                        
                        // window.location.reload()
                    }else{
                        nav_bottom.style.display="none"
                        findP.style.display='block'
                        findP.innerHTML=`共查找到<b>${data.data.object.length}</b>条数据`
                        tybody.innerHTML=''
                        // let i;
                        
                        for(i=0; i<data.data.object.length; i++){
                            tybody.innerHTML +=`
                            <tr>
                                <td><input type="checkbox" class="checkbox"  onclick="checkboxFun()" name="${data.data.object[i].interviewersId}" target="${i}"  ></td>
                                <td>${i+1}、${data.data.object[i].name}</td>
                                <td>${data.data.object[i].classes}</td>
                                <td>${data.data.object[i].studentId}</td>
                                <td>${data.data.object[i].state}</td>
                                <td>
                                <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="seejudgeFun()" target="${data.data.object[i].interviewersId}" name="${data.data.object[i].classes+data.data.object[i].name}" style="background-color:#ff4700">
                            评论
                        </button>
                                    <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="openCheckWindow()" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}" >
                                    详情
                                    </button>
                                    <button class="layui-btn layui-btn-sm layui-btn-sm" onclick="openChangeWindowFun()" _id="${data.data.object[i].interviewersId}" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}" >
                                        变更
                                    </button>
                                    <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="delUserFun()"  target="${data.data.object[i].interviewersId}" >
                                        删除
    
                                    </button>
                                   
                                    <button class="layui-btn layui-btn-warm  layui-btn-sm" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}"  name="${data.data.object[i].state}"  onclick="goInterviewFun()" >
                                    开始面试
                                </button>
                                </td>
                            </tr>
                            
                            `
                        }
                    }
                    
                }else{
                    // alert("抱歉未找到")
                    layui.use("layer",function(){
                        layer.msg('抱歉未找到', {
                            icon: 7,
                            time: 2000
                        })
                    })
                }   
                search_input.value = ''  
            })
            .catch(err => {
                console.log(err);
            })
    }
}

// 筛选不同状态的面试者
function filterSort(){
    search_inputText = null;
    console.log(search_inputText);
    let filter = qu('#filter')
    let nav_bottom = qu(".nav_bottom")
    let findP = qu('.findP')
    // console.log(filter.options.length);
    // console.log(filter.options[0].text);
    // console.log(filter.options[1].text);
    // console.log(filter.value);
    // for(let j=0;j<filter.options.length;){
    //     if(!filter.options[j].text){
    //         j++
    //     }else{
        if(filter.value=='所有人'){
            window.location.reload()
        }else{
            axios({
                url:'/admin/index/findInterviewersByState',
                method:'GET',
                params:{
                    state:filter.value
                }
            })
            .then(data => {
                // console.log(data);
                // console.log(data.status);
                if (data.status==200) {
                    // if(filter.value=='所有人'){
                    //     findP.style.display='none'
                    //     nav_bottom.style.display="block"
                    // }else{
                        if(data.data.length==0){
                            // alert('已无该类面试者！')
                            layui.use("layer",function(){
                                layer.msg('已无该类面试者', {
                                    icon: 2,
                                    time: 2000
                                })
                            })
                            // window.location.reload()
                        }else{
                            checkAll.checked=false;
                            dels = [];
                            findP.style.display='block'
                            nav_bottom.style.display="none"
                            findP.innerHTML=`<b>${filter.value}</b>共查找到<b>${data.data.length}</b>条数据`
                            tybody.innerHTML=''
                            console.log(data);
                            // let i;
                            for(i=0; i<data.data.length; i++){
                                tybody.innerHTML +=`
                                <tr>
                                    <td><input type="checkbox" class="checkbox"  onclick="checkboxFun()" name="${data.data[i].interviewersId}" target="${i}"></td>
                                    <td>${i+1}、${data.data[i].name}</td>
                                    <td>${data.data[i].classes}</td>
                                    <td>${data.data[i].studentId}</td>
                                    <td>${data.data[i].state}</td>
                                    <td>
                                    <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="seejudgeFun()" target="${data.data[i].interviewersId}" name="${data.data[i].classes+data.data[i].name}" style="background-color:#ff4700">
                                    评论
                                </button>
                                        <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="openCheckWindow()" target="${data.data[i].studentId}" name="${data.data[i].state}" >
                                        详情
                                        </button>
                                        <button class="layui-btn layui-btn-sm layui-btn-sm" onclick="openChangeWindowFun()" _id="${data.data[i].interviewersId}" target="${data.data[i].studentId}" name="${data.data[i].state}">
                                            变更
                                        </button>
                                        <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="delUserFun()"  target="${data.data[i].interviewersId}" >
                                            删除

                                        </button>
                                        <button class="layui-btn layui-btn-warm  layui-btn-sm"  target="${data.data[i].studentId}" name="${data.data[i].state}"  name="${data.data[i].state}"  onclick="goInterviewFun()">
                                            开始面试
                                        </button>
                                    </td>
                                </tr>
                                `
                            }
                        }
                        
                    
                    
                }else{
                    // alert('抱歉未找到')
                    layui.use("layer",function(){
                        layer.msg('抱歉未找到', {
                            icon: 7,
                            time: 2000
                        })
                    })
                }
            })
            .catch(err => {
                console.log(err);
            })
        }
            
        }
function changeInfoOkFun(){
    let infoForm  = document.getElementById('infoForm');
    let resultInfo = serializeToJson($(infoForm))
    console.log(resultInfo);
    if(!ischina(resultInfo.name)){
        layui.use("layer",function(){
            layer.msg('学生姓名必须填写中文', {
                icon: 7,
                time: 2000
            })
        })
		return false;  
	}
    // if(!isStudentNo(resultInfo.studentId)){
    //     layui.use("layer",function(){
    //         layer.msg('学号必须为11位', {
    //             icon: 7,
    //             time: 2000
    //         })
    //     })
	// 	return false;  
	// }
    if(!isTelCode(resultInfo.Telephone)){
        layui.use("layer",function(){
            layer.msg('请检查电话号码是否有误', {
                icon: 7,
                time: 2000
            })
        })
		return false;
	}
    if(!isQq(resultInfo.qq)){
        layui.use("layer",function(){
            layer.msg('请检查qq号码是否有误', {
                icon: 7,
                time: 2000
            })
        })
		return false;  
	}
    if(resultInfo.sex !='男' && resultInfo.sex!='女'){
        layui.use("layer",function(){
            layer.msg('性别只能为男或女', {
                icon: 7,
                time: 2000
            })
        })
		return false;   
    }
    console.log(interviewIdOrigin);
    console.log(studentIdA.value);
    axios({
        url:"/admin/index/updateInterviewer",
        method:"GET",
        params: {
            name: resultInfo.name,
            classes: resultInfo.classes,
            sex: resultInfo.sex,
            studentId: studentIdA.value,
            Telephone: resultInfo.Telephone,
            qq: resultInfo.qq,
            interviewersId:interviewIdOrigin
        }
    })
    .then(data=>{
        console.log(data.data);
        if(data.data.code == 200){
            closeChangeWindowFun();
            layui.use("layer",function(){
                layer.msg('修改成功', {
                    icon: 1,
                    time: 2000
                })
            })
            if(search_inputText == null){
                if(filter.value=='所有人'){
                    getData(page,pageSize);
                }else{
                    filterSort();
                }
            }else{
                seekFunOk();
            }
            // search_inputText();
        }else{
            alert(data.data.message)
        }
    //    console.log(data.data);
    })
    .catch(err=>{
        // res.send(err)
        console.log(err);
    })
}
//正则判断

/*校验是否中文名称组成 */
function ischina(str) {
	var reg=/^[\u4E00-\u9FA5]{2,4}$/;   /*定义验证表达式*/
	return reg.test(str);     /*进行验证*/
}
/*校验是否全由11位数字组成 */
function isStudentNo(str) {
	var reg=/^[0-9]{11}$/;   /*定义验证表达式*/
	return reg.test(str.trim());     /*进行验证*/
}
/*校验是否全由11位数字组成 */
function isQq(str) {
	var reg=/^\d{5,11}$/;   /*定义验证表达式*/
	return reg.test(str);     /*进行验证*/
}
//批量设置状态
var change_ok = document.getElementById('change_ok');
var flagChangeType = 0 ;
function changeStateMore(){
    console.log(dels);
    if(dels.length==0){
        layui.use("layer",function(){
            layer.msg('请选择要操作的面试者', {
                icon: 7,
                time: 2000
            })
        })
    }else{
        openChangeWindowFun();
        flagChangeType = 1;
        console.log(flagChangeType);
    }
}
function changeOkFunA(){
    flagChangeType = 0;
    console.log('Ok');
    for(let key of dels){
        changeStateFunB(key)
    }
    getData(page,pageSize);
    layui.use("layer",function(){
        layer.msg('修改成功', {
            icon: 1,
            time: 2000
        })
    })
    if(filter.value=='所有人'){
        getData(page,pageSize);
    }else{
        filterSort();
    }
    checkAll.checked = false;
}
function changeStateFunB(id){
    axios({
        url:'/admin/index/changeStateMore',
        method:'GET',
        params: {
            state: state,
            ids: id
        }
    })
}
let findFlag = document.getElementById('findFlag')
function fliterFlag(){
    console.log(findFlag.value);
    let search_input = document.querySelector('#search_input')
    if(findFlag.value=='0'){
        search_input.setAttribute('placeholder',' 输入姓名')
    }else{
        search_input.setAttribute('placeholder',' 输入班级')
    }
}
var search_inputText = null;
function seekFunOk(){
    console.log(search_inputText);

    axios({
        url:"/admin/index/findByNameLike",
        method:"GET",
        params: {
            name:search_inputText,
            choose:findFlag.value 
            }
        })
        .then(data=>{
            // console.log(data.data.data[0]);
            // console.log(data.data.object);
            // console.log(data.data.object.length);
            // console.log(data.data.length);
            // console.log(data.status);
            if(data.status==200){   
                if(data.data.object==null){
                    // alert('抱歉未找到')
                    layui.use("layer",function(){
                        layer.msg('抱歉未找到', {
                            icon: 7,
                            time: 2000
                        })
                    })
                    
                    // window.location.reload()
                }else{
                    // nav_bottom.style.display="none"
                    // findP.style.display='block'
                    // findP.innerHTML='为您查找出以下数据:'
                    // nav_bottom.style.display="none"
                    // findP.style.display='block'
                    let findP = document.getElementsByClassName('findP')[0]
                    findP.innerHTML=`共查找到<b>${data.data.object.length}</b>条数据`
                    tybody.innerHTML=''
                    // let i;
                    
                    for(i=0; i<data.data.object.length; i++){
                        tybody.innerHTML +=`
                        <tr>
                            <td><input type="checkbox" class="checkbox"  onclick="checkboxFun()" name="${data.data.object[i].interviewersId}" target="${i}"  ></td>
                            <td>${i+1}、${data.data.object[i].name}</td>
                            <td>${data.data.object[i].classes}</td>
                            <td>${data.data.object[i].studentId}</td>
                            <td>${data.data.object[i].state}</td>
                            <td>
                            <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="seejudgeFun()" target="${data.data.object[i].interviewersId}" name="${data.data.object[i].classes+data.data.object[i].name}" style="background-color:#ff4700">
                            评论
                        </button>
                                <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="openCheckWindow()" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}" >
                                详情
                                </button>
                                <button class="layui-btn layui-btn-sm layui-btn-sm" onclick="openChangeWindowFun()" _id="${data.data.object[i].interviewersId}" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}" >
                                    变更
                                </button>
                                <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="delUserFun()"  target="${data.data.object[i].interviewersId}" >
                                    删除

                                </button>
                               
                                <button class="layui-btn layui-btn-warm  layui-btn-sm" target="${data.data.object[i].studentId}" name="${data.data.object[i].state}"  name="${data.data.object[i].state}"  onclick="goInterviewFun()" >
                                开始面试
                            </button>
                            </td>
                        </tr>
                        
                        `
                    }
                }
                // search_inputText =-1;
            }else{
                // alert("抱歉未找到")
                layui.use("layer",function(){
                    layer.msg('抱歉未找到', {
                        icon: 7,
                        time: 2000
                    })
                })
            }   
            search_input.value = ''  
        })
}
//回车事件绑定
$('#search_input').bind('keyup', function(event) {
    if (event.keyCode == "13") {
        //回车执行查询
        $('.btn').click();
    }
});

//点击查看评论
var interviewWindow = document.getElementById('interviewWindow')
function seejudgeFun(e){
    let cover_div = document.getElementById('cover_div')
    let interviewHeader = document.getElementById('interviewHeader')
    cover_div.style.display='block';
    interviewWindow.style.display='block';
    e=e || window.event;
    var target=e.target || e.srcElement;
    console.log(target.getAttribute('target'));
    console.log(target.getAttribute('name'));
    let tybodyA = document.getElementById('tybodyA');
    axios({
        url:"/admin/interview/findCommen",
        method:"GET",
        params:{
            interviewersId :target.getAttribute('target'),
            state: "待三面",
        }
        }).then(data=>{
            console.log(data.data);
            tybodyA.innerHTML=''
            interviewHeader.innerHTML=''
            interviewHeader.innerHTML =`
            <h4>${target.getAttribute('name')}的评论</h4>
            `
            for(let i=0;i<data.data.length;i++){
                tybodyA.innerHTML+=`
                <tr>
                <td class="commen_td"  style="min-width:100px">${data.data[i].username}</td>
                <td>${data.data[i].content}</td>
                <td class="commen_td"  style="min-width:120px">
                    ${data.data[i].state}
                </td>
            </tr>
                `
            }
            if(data.data.length==0){
                tybodyA.innerHTML+=`
                <tr>
                    <td class="commen_td" style="min-width:100px"> </td>
                    <td>暂无面试官评论</td>
                    <td class="commen_td"  style="min-width:120px">
                        
                    </td>
                </tr>
                `
            }
        });
}